package com.health.common.auth.model.enums;


import lombok.Getter;

/**
 * @author zhexueqi
 * @ClassName UserRoleEnum
 * @since 2024/8/19    11:35
 */
@Getter
public enum UserRoleEnum {
    PATIENT("patient", "1"),
    DOCTOR("doctor", "2"),
    HOSPITAL("hospital", "3"),
    PRODUCER("producer", "4"),
    TRANSPORTER("transporter", "5"),
    ADMIN("admin", "6"),
    /**
     * 禁用
     */
    BAN("ban", "禁用");

    private final String role;
    private final String description;

    UserRoleEnum(String role, String description) {
        this.role = role;
        this.description = description;
    }

    public static UserRoleEnum getEnumByRole(String role) {
        for (UserRoleEnum value : UserRoleEnum.values()) {
            if (value.getRole().equals(role)) {
                return value;
            }
        }
        return null;
    }
    public static UserRoleEnum getEnumByValue(String value) {
        for (UserRoleEnum valueEnum : UserRoleEnum.values()) {
            if (valueEnum.getRole().equals(value)) {
                return valueEnum;
            }
        }
        return null;
    }
}
